/*
 * CMarkup.cpp
 *
 *  Created on: 4 oct. 2009
 *      Author: Maxime Gaudin
 */
#include "CMarkup.h"

#ifndef IOSTREAM_HEADER
	#include <iostream>
	#define IOSTREAM_HEADER
#endif

CMarkup::CMarkup(std::string Name, std::string Content)
{
	name = Name;
	content = Content;
}

CMarkup::~CMarkup() {}

// Getters ==========================================
std::string CMarkup::getName()		{return name;}
std::string CMarkup::getContent()	{return content;}

int CMarkup::getSubMarkupCount() 	{return (int)subMarkups.size();}
// ==================================================

void CMarkup::AddSubMarkup(CMarkup::CMarkup* SubMarkup)
{
	subMarkups.push_back(SubMarkup);
}

CMarkup::CMarkup* CMarkup::GetSubMarkup(int Index)
{
	if(Index >= 0 && Index < (int)subMarkups.size())
		return subMarkups[Index];

	return NULL;
}

std::string CMarkup::toString()
{
	std::string tmpStr;

	tmpStr.append("<");
	tmpStr.append(name);
	tmpStr.append(">\n");

	tmpStr.append(content);
	tmpStr.append("\n");

	tmpStr.append("<");
	tmpStr.append(name);
	tmpStr.append("/>\n");

	return tmpStr;
}
